-
Notifications
You must be signed in to change notification settings - Fork 2.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make cash have all betas enabled when running in development mode #3135
Conversation
src/libs/Permissions.js
Outdated
@@ -9,12 +11,14 @@ Onyx.connect({ | |||
callback: val => betas = val || [], | |||
}); | |||
|
|||
const isDevelopment = lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was thinking you should use getEnvironment()
from the Environment
module so that it will be cross-platform. However, that will also force this code to be async, which will be a pain to refactor. I believe it's only necessary to use getEnvironement()
if you care about the difference between production and staging. Since you don't, it might be good to add a method to the Environment
module called isDevelopment()
which is a synchronous function (and then add method docs to explain why it's OK for it to be synchronous when getEnvironment()
has to be async).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Why is that method returning a Promise
?
Could we alternatively just use the __DEV__
global? It is being set here...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting. Why is that method returning a Promise?
Why indeed, given it is getting a value from an already loaded object. Any objections to change that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The mobile versions of the environment module need to make a network request to get the info about if it's in staging or production. That's why it needs to be async.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh I see now, because only the web app uses the staging env configs and the native apps always use production config, but we need to know if they are TestFlight or google play beta versions.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, true, did not notice that. So what is preferred to add a isDevelopment that's not async or use the __DEV__
global? If the latter, not sure how I grab that constant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel they are different concepts. It just happens that we are running in __DEV__
mode when we are using the development environment. But we could also be running the development environment (i.e. not staging or production) and not be "running in dev mode".
Regardless, I'd think we want the environment in this case since whether you are running in dev mode or not the betas would probably be enabled in the "development environment".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about solving this from the API side? If PHP sends all
in the beta information, then we should be fine. And PHP knows whether we are in DEBUG mode or not.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is A LOT harder to detect where the request is coming from, from the server than in the client... keep in mind this has to work for contributors that do not point the API to the dev environment, since they don't have one.
Ah, that's right... It wouldn't work well for contributors. OK, scrap that
idea then.
…On Tue, May 25, 2021 at 5:22 PM Ionatan Wiznia ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/libs/Permissions.js
<#3135 (comment)>
:
> @@ -9,12 +11,14 @@ Onyx.connect({
callback: val => betas = val || [],
});
+const isDevelopment = lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV) === CONST.ENVIRONMENT.DEV;
It is A LOT harder to detect where the request is coming from the
server... keep in mind this has to work for contributors that do not point
the API to the dev environment, since they don't have one.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#3135 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAJMAB373HQJATRKLJECCETTPQWMFANCNFSM45QGD2VA>
.
|
Alright, updated |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks pretty straightforward and good to me!
@@ -0,0 +1,12 @@ | |||
import lodashGet from 'lodash/get'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was trying to figure out why this was in it's own file, and then it dawned on me why you did this (and I totally see the logic). I'm not sure it's what we want though. This doesn't really fit our cross-platform pattern because there is a cross-platform module (Environment
) that is sharing non-platform specific methods (isDevelopment
).
I think rather we should have Environment
be non-platform specific and then making only the pieces that need to be platform-specific (getEnvironment
in this case) would be split into their platform files.
I hope that makes sense?
256ab7e
to
77054aa
Compare
Updated and retested |
import CONST from '../../CONST'; | ||
import getEnvironment from './getEnvironment'; | ||
|
||
function isDevelopment() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs a method doc for the return value.
* @returns {Promise} | ||
*/ | ||
function isBetaBuild() { | ||
return new Promise(resolve => resolve(false)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can simply be
return new Promise(resolve => resolve(false)); | |
return Promise.resolve(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll have to double-check that it works, but I think it does according to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/resolve
@@ -11,6 +11,4 @@ function getEnvironment() { | |||
return new Promise(resolve => resolve(lodashGet(Config, 'ENVIRONMENT', CONST.ENVIRONMENT.DEV))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These could also use a more simple return Promise.resolve()
@@ -1,7 +1,7 @@ | |||
import lodashGet from 'lodash/get'; | |||
import Config from 'react-native-config'; | |||
import betaChecker from './betaChecker'; | |||
import CONST from '../../CONST'; | |||
import betaChecker from '../betaChecker/index'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import betaChecker from '../betaChecker/index'; | |
import betaChecker from '../betaChecker'; |
No need for that. The modules are smart enough to figure it out
Updated |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
Details
Fixed Issues
Fixes https://expensify.slack.com/archives/C03TQ48KC/p1621974182298000
Tests
[]
QA Steps
None, since this is just for dev
Tested On